package day017.homework.p3;

public class Student {
    private String name;
    private String sex;
    private int age;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setSex(String sex) throws SexException {
        if (!(sex.equals("男")) && !(sex.equals("女"))) {
            throw new SexException("性别只能为男/女");
        } else {
            this.sex = sex;
        }
    }

    public String getSex() {
        return this.sex;
    }

    public void setAge(int age) throws AgeException {
        if (age < 15 || age > 50) {
            throw new AgeException("年龄只能在15-50之间!");
        } else {
            this.age = age;
        }
    }

    public int getAge() {
        return this.age;
    }
}
